package org.chnxi.study.serialize.gson;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
import lombok.Data;
import lombok.ToString;

import java.util.List;

@Data
public class EnglishTeacher implements Teacher {

    private String name;

    public EnglishTeacher(){
        this.name = "英语老师";
    }

    @Override
    public String name() {
        return name;
    }

    private transient List<Student> studentes;

    @Override
    public String toString() {
        GsonBuilder builder = new GsonBuilder();
        builder.registerTypeAdapter(Teacher.class, new TeacherAdapterForGson());
        Gson mygson = builder.create();
        return mygson.toJson(this);
    }
}
